/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Vista;

import Modelo.Causa;
import Modelo.Producto;
import Modelo.Recepcion_Judicial;
import Modelo.Recepcion_Voluntaria;
import Modelo.Relacion;
import java.util.ArrayList;
import java.util.Iterator;
import javax.swing.JFrame;
import javax.swing.JOptionPane;

/**
 *
 * @author Bastian
 */
public class Panel_ResumenRecepcion extends javax.swing.JPanel {

    /**
     * Creates new form Panel_ResumenRecepcion
     */
    
    private VentanaPrincipal V_Principal;
    private boolean esJudicial, esVoluntaria;
    protected ArrayList<ArrayList> LosProductos;
    protected ArrayList LaCausa,LaRecepcion;
    
    public Panel_ResumenRecepcion() {
        initComponents();
        LosProductos = new ArrayList<ArrayList>();
        LaCausa = new ArrayList();
        LaRecepcion = new ArrayList();
        
    }
    
    public void Limpiar(){
        
        this.TextField_ID.setText("");
        this.jDateChooser_Fecha.setDate(null);
           
        this.TextField_Rol.setText("");
        this.jDateChooser_FeDevolucion.setDate(null);
        this.jTextField_Bodegaje.setText("");
        this.jTextField_Demandado.setText("");
        this.jTextField_Demandante.setText("");
        this.TextField_RUT.setText("");
        //this.tabla_Producto1.BorraProductos();

    }
    
    //Se asume que los arraylist fueron inicializados en los paneles anteriores
    public void Inicializar(){
        
        this.Limpiar();
        if(esJudicial){
        //panel principal
            this.TextField_ID.setText(LaRecepcion.get(0).toString());
            this.jDateChooser_Fecha.setDate((java.util.Date)LaRecepcion.get(1));
            
            //Panel ReJudicial
            this.TextField_Rol.setText(LaCausa.get(0).toString());
            this.jDateChooser_FeDevolucion.setDate((java.util.Date)LaRecepcion.get(2));
            this.jTextField_Bodegaje.setText(LaRecepcion.get(5).toString());
            this.jTextField_Demandado.setText(LaRecepcion.get(4).toString());
            this.jTextField_Demandante.setText(LaRecepcion.get(3).toString());
        }
        
        else if (esVoluntaria){
        //Panel Principal
            this.TextField_ID.setText(LaRecepcion.get(0).toString());
            this.jDateChooser_Fecha.setDate((java.util.Date)LaRecepcion.get(1));
        //Panel ReVoluntaria
            this.TextField_RUT.setText(LaRecepcion.get(3).toString());
        }
    
    }
    
    
    
    public void setFrame(JFrame f){
        this.V_Principal= (VentanaPrincipal) f;
        esJudicial = false;
        esVoluntaria=false;
    }
    
    public void esJudicial(){
        esJudicial = true;
        esVoluntaria = false;
    }
    
    public void esVoluntaria(){
        esVoluntaria= true;
        esJudicial = false;
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel_Remate = new javax.swing.JLabel();
        jButton_Aceptar = new javax.swing.JButton();
        jButton_Cancelar = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        Label_ID = new javax.swing.JLabel();
        TextField_ID = new javax.swing.JTextField();
        jLabel_FeIngreso = new javax.swing.JLabel();
        jDateChooser_Fecha = new com.toedter.calendar.JDateChooser();
        jPanel2 = new javax.swing.JPanel();
        jDateChooser_FeDevolucion = new com.toedter.calendar.JDateChooser();
        jTextField_Bodegaje = new javax.swing.JTextField();
        jLabel_Bodegaje = new javax.swing.JLabel();
        jLabel_FeDevolucion = new javax.swing.JLabel();
        jTextField_Demandado = new javax.swing.JTextField();
        jLabel_Demandado = new javax.swing.JLabel();
        jTextField_Demandante = new javax.swing.JTextField();
        jLabel_Demandante = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        Label_Rol = new javax.swing.JLabel();
        TextField_Rol = new javax.swing.JTextField();
        jPanel3 = new javax.swing.JPanel();
        Label_RUT = new javax.swing.JLabel();
        TextField_RUT = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tabla_Producto1 = new Vista.Tablas.Tabla_Producto();
        jButton_EliminarProductos = new javax.swing.JButton();
        jButton_AgregarProductos = new javax.swing.JButton();
        jLabel_ListaProductos = new javax.swing.JLabel();

        setMaximumSize(new java.awt.Dimension(1000, 550));
        setMinimumSize(new java.awt.Dimension(1000, 550));
        setPreferredSize(new java.awt.Dimension(1000, 550));

        jLabel_Remate.setFont(new java.awt.Font("Arial", 0, 36)); // NOI18N
        jLabel_Remate.setText("Resumen Recepción");

        jButton_Aceptar.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        jButton_Aceptar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Vista/Imagenes_Files/tick/24.png"))); // NOI18N
        jButton_Aceptar.setText("Aceptar");
        jButton_Aceptar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_AceptarActionPerformed(evt);
            }
        });

        jButton_Cancelar.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        jButton_Cancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Vista/Imagenes_Files/cruz/24.png"))); // NOI18N
        jButton_Cancelar.setText("Cancelar");
        jButton_Cancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_CancelarActionPerformed(evt);
            }
        });

        jPanel1.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));

        Label_ID.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        Label_ID.setText("ID Recepción");

        TextField_ID.setEditable(false);
        TextField_ID.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        TextField_ID.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                TextField_IDKeyTyped(evt);
            }
        });

        jLabel_FeIngreso.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        jLabel_FeIngreso.setText("Fecha Ingreso");

        jDateChooser_Fecha.setEnabled(false);
        jDateChooser_Fecha.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        jDateChooser_Fecha.setMaxSelectableDate(new java.util.Date(253370779303000L));
        jDateChooser_Fecha.setMinSelectableDate(new java.util.Date(1262318503000L));
        jDateChooser_Fecha.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jDateChooser_FechaKeyTyped(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel_FeIngreso)
                    .addComponent(Label_ID))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(TextField_ID, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jDateChooser_Fecha, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(70, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(Label_ID)
                    .addComponent(TextField_ID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel_FeIngreso)
                    .addComponent(jDateChooser_Fecha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(7, 7, 7))
        );

        jPanel2.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));

        jDateChooser_FeDevolucion.setEnabled(false);
        jDateChooser_FeDevolucion.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        jDateChooser_FeDevolucion.setMaxSelectableDate(new java.util.Date(253370779303000L));
        jDateChooser_FeDevolucion.setMinSelectableDate(new java.util.Date(1262318503000L));

        jTextField_Bodegaje.setEditable(false);
        jTextField_Bodegaje.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        jTextField_Bodegaje.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTextField_BodegajeKeyTyped(evt);
            }
        });

        jLabel_Bodegaje.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        jLabel_Bodegaje.setText("Bodegaje Pagado ($)");

        jLabel_FeDevolucion.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        jLabel_FeDevolucion.setText("Fecha Devolución");

        jTextField_Demandado.setEditable(false);
        jTextField_Demandado.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        jTextField_Demandado.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTextField_DemandadoKeyTyped(evt);
            }
        });

        jLabel_Demandado.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        jLabel_Demandado.setText("Demandado");

        jTextField_Demandante.setEditable(false);
        jTextField_Demandante.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        jTextField_Demandante.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTextField_DemandanteKeyTyped(evt);
            }
        });

        jLabel_Demandante.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        jLabel_Demandante.setText("Demandante");

        jLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        jLabel1.setText("Recepción Judicial");

        Label_Rol.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        Label_Rol.setText("ROL Causa");

        TextField_Rol.setEditable(false);
        TextField_Rol.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        TextField_Rol.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                TextField_RolKeyTyped(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel_Bodegaje)
                    .addComponent(jTextField_Bodegaje, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jDateChooser_FeDevolucion, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel_Demandado)
                    .addComponent(jTextField_Demandado, javax.swing.GroupLayout.PREFERRED_SIZE, 270, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel_FeDevolucion)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(jLabel_Demandante)
                        .addComponent(jTextField_Demandante, javax.swing.GroupLayout.DEFAULT_SIZE, 270, Short.MAX_VALUE))
                    .addComponent(jLabel1)
                    .addComponent(Label_Rol)
                    .addComponent(TextField_Rol, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(Label_Rol)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 9, Short.MAX_VALUE)
                .addComponent(TextField_Rol, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel_FeDevolucion)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jDateChooser_FeDevolucion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel_Bodegaje)
                .addGap(6, 6, 6)
                .addComponent(jTextField_Bodegaje, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel_Demandante)
                .addGap(6, 6, 6)
                .addComponent(jTextField_Demandante, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel_Demandado)
                .addGap(6, 6, 6)
                .addComponent(jTextField_Demandado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jPanel3.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));

        Label_RUT.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
        Label_RUT.setText("RUT Cliente");

        TextField_RUT.setEditable(false);
        TextField_RUT.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        TextField_RUT.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                TextField_RUTKeyTyped(evt);
            }
        });

        jLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        jLabel2.setText("Recepción Voluntaria");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(Label_RUT)
                    .addComponent(jLabel2)
                    .addComponent(TextField_RUT, javax.swing.GroupLayout.PREFERRED_SIZE, 154, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(138, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(Label_RUT)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(TextField_RUT, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jScrollPane1.setViewportView(tabla_Producto1);

        jButton_EliminarProductos.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        jButton_EliminarProductos.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Vista/Imagenes_Files/no_disponible/24.png"))); // NOI18N
        jButton_EliminarProductos.setText("Eliminar seleccionados");
        jButton_EliminarProductos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_EliminarProductosActionPerformed(evt);
            }
        });

        jButton_AgregarProductos.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        jButton_AgregarProductos.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Vista/Imagenes_Files/producto/24.png"))); // NOI18N
        jButton_AgregarProductos.setText("Agregar Productos");
        jButton_AgregarProductos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_AgregarProductosActionPerformed(evt);
            }
        });

        jLabel_ListaProductos.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
        jLabel_ListaProductos.setText("Lista de Productos");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel_Remate)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 605, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGroup(layout.createSequentialGroup()
                                    .addComponent(jButton_AgregarProductos)
                                    .addGap(18, 18, 18)
                                    .addComponent(jButton_EliminarProductos)))
                            .addComponent(jLabel_ListaProductos))
                        .addGap(31, 31, 31))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(437, 437, 437)
                        .addComponent(jButton_Aceptar)
                        .addGap(9, 9, 9)
                        .addComponent(jButton_Cancelar)
                        .addContainerGap())))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel_Remate)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap())
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel_ListaProductos)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 296, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jButton_AgregarProductos, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jButton_EliminarProductos, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(86, 86, 86)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jButton_Aceptar)
                            .addComponent(jButton_Cancelar))
                        .addContainerGap())))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void jButton_AceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_AceptarActionPerformed
        // TODO add your handling code here:
        //ENVIAR INFORMACION
        
        //Guardar Causa
        
        
        //Guardar Recepcion
        if(esJudicial){
            Causa.nueva(LaCausa);
            Recepcion_Judicial.nuevo(LaRecepcion);
        }
        
        else if(esVoluntaria){
            Recepcion_Voluntaria.nuevo(LaRecepcion);
        }
        
        //Guardar Productos y relacion Recepcion_hasProducto
        for (Iterator<ArrayList> it = LosProductos.iterator(); it.hasNext();) {
            ArrayList pro = it.next();
            Producto.nuevo(pro);
            
            int ID_Recepcion = Integer.parseInt(LaRecepcion.get(0).toString());
            int ID_Producto = Integer.parseInt(pro.get(0).toString());
            
            if(esJudicial) Relacion.recepcion_judicial_has_producto(ID_Recepcion, ID_Producto);
            
            else if(esVoluntaria) Relacion.recepcion_voluntaria_has_producto(ID_Recepcion, ID_Producto);
        }
        
        
        JOptionPane.showMessageDialog(V_Principal, "Datos agregados correctamente", "Información", JOptionPane.INFORMATION_MESSAGE);
        V_Principal.removePanel_ResumenRecepcion();
        if(esJudicial){
            V_Principal.removePanel_ReJudicial();
            V_Principal.removePanel_Causa();
        }
        
        else if(esVoluntaria){
            V_Principal.removePanel_ReVoluntaria();
        }
        
        V_Principal.addPanel_Bienvenido();
        V_Principal.desbloquearPanel();
    }//GEN-LAST:event_jButton_AceptarActionPerformed

    private void jButton_CancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_CancelarActionPerformed
        // TODO add your handling code here:
        //this.Limpiar();
        //V_Principal.removePanel_ReVoluntaria();
        V_Principal.removePanel(this);
        V_Principal.desbloquearPanel(0);
    }//GEN-LAST:event_jButton_CancelarActionPerformed

    private void TextField_IDKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_TextField_IDKeyTyped
        // TODO add your handling code here:
        char c = evt.getKeyChar();

        if (!Character.isDigit(c) || this.TextField_ID.getText().length() > 10) {
            evt.consume();
        }
    }//GEN-LAST:event_TextField_IDKeyTyped

    private void TextField_RolKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_TextField_RolKeyTyped
        // TODO add your handling code here:
    }//GEN-LAST:event_TextField_RolKeyTyped

    private void jDateChooser_FechaKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jDateChooser_FechaKeyTyped
        // TODO add your handling code here:
        char c = evt.getKeyChar();
        if (!Character.isDigit(c) && c != '-') {
            evt.consume();
        }
    }//GEN-LAST:event_jDateChooser_FechaKeyTyped

    private void jTextField_BodegajeKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextField_BodegajeKeyTyped
        // TODO add your handling code here:
        char c = evt.getKeyChar();
        if (!Character.isDigit(c) || this.jTextField_Bodegaje.getText().length() > 10) {
            evt.consume();
        }
    }//GEN-LAST:event_jTextField_BodegajeKeyTyped

    private void jTextField_DemandadoKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextField_DemandadoKeyTyped
        // TODO add your handling code here:
        char c = evt.getKeyChar();
        if ((!Character.isWhitespace(c)
                && !Character.isLetter(c)) || this.jTextField_Demandado.getText().length() > 100) {
            evt.consume();
        }
    }//GEN-LAST:event_jTextField_DemandadoKeyTyped

    private void jTextField_DemandanteKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextField_DemandanteKeyTyped
        // TODO add your handling code here:
        char c = evt.getKeyChar();
        if ((!Character.isWhitespace(c)
                && !Character.isLetter(c)) || this.jTextField_Demandante.getText().length() > 100) {
            evt.consume();
        }
    }//GEN-LAST:event_jTextField_DemandanteKeyTyped

    private void TextField_RUTKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_TextField_RUTKeyTyped
        // TODO add your handling code here:
    }//GEN-LAST:event_TextField_RUTKeyTyped

    private void jButton_EliminarProductosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_EliminarProductosActionPerformed
        // TODO add your handling code here:

        if (this.tabla_Producto1.getCantidadProductos() == 0) {
            JOptionPane.showMessageDialog(V_Principal, "¡No hay productos en la lista!", "Error", JOptionPane.ERROR_MESSAGE);
            return;
        }

        int x = JOptionPane.showConfirmDialog(V_Principal, "¿Desea borrar los productos seleccionados?", "Eliminar Produtod",
                JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);

        //x=0 --> si | x=1 --> no

        if (x == 0) {
            this.tabla_Producto1.BorraProductosSeleccionados();
            this.tabla_Producto1.repaint();
            LosProductos = tabla_Producto1.getProductos();
        }
    }//GEN-LAST:event_jButton_EliminarProductosActionPerformed

    private void jButton_AgregarProductosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_AgregarProductosActionPerformed
        // TODO add your handling code here:

        /*
         * ESTE METODO DEBE ABRIR OTRA PESATAÑA PARA BUSCAR PRODUCTOS, MIENTRAS
         * LA PESTAÑA CON ESTE PANEL SE MANTIENE ABIERTA PERO DESHABILITADA
         */

        /*
         * A MEDIDA QUE SE AGREGAN PRODUTOS TIENEN QUE CALCULARSE LOS VALORES DE
         * COMISION, IVA, SUBTOTAL Y PRECIO TOTAL
         */
        
        if(esJudicial){
            V_Principal.addPanel_Producto(true,1);
            V_Principal.bloquearPanel(2);
        }
        
        else if(esVoluntaria){
            V_Principal.addPanel_Producto(true,2);
            V_Principal.bloquearPanel(1);
        }
    }//GEN-LAST:event_jButton_AgregarProductosActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel Label_ID;
    private javax.swing.JLabel Label_RUT;
    private javax.swing.JLabel Label_Rol;
    private javax.swing.JTextField TextField_ID;
    private javax.swing.JTextField TextField_RUT;
    private javax.swing.JTextField TextField_Rol;
    private javax.swing.JButton jButton_Aceptar;
    private javax.swing.JButton jButton_AgregarProductos;
    private javax.swing.JButton jButton_Cancelar;
    private javax.swing.JButton jButton_EliminarProductos;
    private com.toedter.calendar.JDateChooser jDateChooser_FeDevolucion;
    private com.toedter.calendar.JDateChooser jDateChooser_Fecha;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel_Bodegaje;
    private javax.swing.JLabel jLabel_Demandado;
    private javax.swing.JLabel jLabel_Demandante;
    private javax.swing.JLabel jLabel_FeDevolucion;
    private javax.swing.JLabel jLabel_FeIngreso;
    private javax.swing.JLabel jLabel_ListaProductos;
    private javax.swing.JLabel jLabel_Remate;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextField jTextField_Bodegaje;
    private javax.swing.JTextField jTextField_Demandado;
    private javax.swing.JTextField jTextField_Demandante;
    protected Vista.Tablas.Tabla_Producto tabla_Producto1;
    // End of variables declaration//GEN-END:variables
}
